home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / GX Libraries / FontLibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-27  |  19.5 KB  |  512 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        FontLibrary.c
  4.  
  5.     Contains:    graphics libraries - gxFont library routines
  6.  
  7.     Written by:    Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Mike Reed, Oliver Steele, David Van Brink, Chris Yerga
  8.  
  9.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.          <4>     6/26/95    TD        fixing return matching style implementation
  14.          <3>      5/1/95    jtd        bringing in final 1.1 source changes
  15.          <2>      1/9/95    JD        changed 'boolean' to 'Boolean'
  16.          <1>      1/9/95    JD        First checked in.
  17. */
  18.  
  19. #include <Memory.h>
  20. #include <Quickdraw.h>
  21. #include <GXGraphics.h>
  22. #include <GXFonts.h>
  23. #include "FontLibrary.h"
  24. #include "GraphicsLibraries.h"
  25.  
  26. #ifdef THINK_C
  27. #pragma options(signed_pstrs)   /* for Think C 5.0 */
  28. #endif
  29. #ifdef MacintoshIncludes
  30.     #define NewString gNewString
  31. #endif
  32.  
  33. typedef struct {
  34.     gxFont        fontID;
  35.     char*   fullName;
  36. } fontNameRecord;
  37.  
  38. static fontNameRecord commonLibraryFonts[] = {
  39.     { nil, "Chicago" },
  40.     { nil, "Courier" },
  41.     { nil, "Geneva" },
  42.     { nil, "Helvetica" },
  43.     { nil, "Monaco" },
  44.     { nil, "New York" },
  45.     { nil, "Symbol" },
  46.     { nil, "Times Roman" }
  47. };
  48.  
  49.  
  50. /***********************************
  51.  *  gxShape and gxStyle library routines to handle  fonts *
  52.  ***********************************/
  53.  
  54. gxFont GetCommonFont(commonFont fontIndex)
  55. {
  56.     if (fontIndex >= firstCommonFont && fontIndex <= lastCommonFont)
  57.     {   if (commonLibraryFonts[fontIndex].fontID == nil)
  58.             commonLibraryFonts[fontIndex].fontID = FindCNameFont(gxFullFontName, commonLibraryFonts[fontIndex].fullName);
  59.         return commonLibraryFonts[fontIndex].fontID;
  60.     }
  61.     return GXGetDefaultFont();
  62. }
  63.  
  64. void SetShapeCommonFont(gxShape s, commonFont fontIndex)
  65. {
  66.     GXSetShapeFont(s, GetCommonFont(fontIndex));
  67. }
  68.  
  69. void SetStyleCommonFont(gxStyle s, commonFont fontIndex)
  70. {
  71.     GXSetStyleFont(s, GetCommonFont(fontIndex));
  72. }
  73.  
  74. static long CLength(const char *name)
  75. {
  76.     const char *nameEnd = name;
  77.     
  78.     while ((*nameEnd++) != 0)
  79.         ;
  80.     return nameEnd - name - 1;
  81. }
  82.  
  83. gxFont FindCNameFont(gxFontName meaning, const char* name)
  84. {
  85.     gxFont fontID = nil;
  86.     GXFindFonts(0, meaning, gxMacintoshPlatform, gxRomanScript, gxEnglishLanguage, CLength(name), (unsigned char *) name, 1, 1, &fontID);
  87.     return fontID;
  88. }
  89.  
  90. gxFont FindPNameFont(gxFontName meaning, const unsigned char name[])
  91. {
  92.     gxFont fontID = nil;
  93.     GXFindFonts(0, meaning, gxMacintoshPlatform, gxRomanScript, gxEnglishLanguage, name[0], &name[1], 1, 1, &fontID);
  94.     return fontID;
  95. }
  96.  
  97. /************ gxFont names *************/
  98.  
  99. long FindFontCName(gxFont fontID, gxFontName meaning, char name[])
  100. {
  101.     long length = GXFindFontName(fontID, meaning, gxMacintoshPlatform, gxRomanScript, gxEnglishLanguage, (unsigned char*)name, nil);
  102.  
  103.     if (name)
  104.         name[length] = 0;
  105.     return length;
  106. }
  107.  
  108. long FindFontPName(gxFont fontID, gxFontName meaning, unsigned char name[])
  109. {
  110.     long length = GXFindFontName(fontID, meaning, gxMacintoshPlatform, gxRomanScript, gxEnglishLanguage, &name[1], nil);
  111.  
  112.     if (name)
  113.         name[0] = length;
  114.     return length;
  115. }
  116.  
  117. long FindStyleFontCName(gxStyle s, gxFontName meaning, char name[])
  118.  {
  119.     gxFont fontID = GXGetStyleFont(s);
  120.     return(FindFontCName(fontID, meaning, name));
  121.  }
  122.  
  123. long FindStyleFontPName(gxStyle s, gxFontName meaning, unsigned char name[])
  124.  {
  125.     gxFont fontID = GXGetStyleFont(s);
  126.     return(FindFontPName(fontID, meaning, name));
  127.  }
  128.  
  129. void SetStylePNamedFont(gxStyle s, const unsigned char name[])
  130. {
  131.     gxFont fontID = FindPNameFont(gxFullFontName, name);
  132.     if (fontID != GXGetStyleFont(s))
  133.         GXSetStyleFont(s, fontID);
  134. }
  135.  
  136. void SetStyleCNamedFont(gxStyle s, const char* name)
  137. {
  138.     gxFont fontID = FindCNameFont(gxFullFontName, name);
  139.     if (fontID != GXGetStyleFont(s))
  140.         GXSetStyleFont(s, fontID);
  141. }
  142.  
  143. /************************
  144.  *  Routines for using GXFindFonts
  145.  ************************/
  146.  
  147. long CountFontFamilies(void)
  148. {
  149.     return GXFindFonts(nil, gxFamilyFontName, 0, 0, 0, 0, nil, 1, gxSelectToEnd, nil);
  150. }
  151.  
  152. gxFont FindFontFamily(long index, gxFontPlatform platform, gxFontScript script, gxFontLanguage language,
  153.     long nameLength, const unsigned char *name)
  154. {
  155.     gxFont fontID = nil;
  156.     GXFindFonts(nil, gxFamilyFontName, platform, script, language, nameLength, name, index, 1, &fontID);
  157.     return fontID;
  158. }
  159.  
  160. long CountFontStyles(gxFont family)
  161. {
  162.     return GXFindFonts(family, 0, 0, 0, 0, 0, nil, 1, gxSelectToEnd, nil);
  163. }
  164.  
  165. static gxFont GetFontStyle(gxFont family, long index)
  166. {
  167.     gxFont fontID = nil;
  168.     GXFindFonts(family, 0, 0, 0, 0, 0, nil, index, 1, &fontID);
  169.     return fontID;
  170. }
  171.  
  172. gxFont FindFontStyle(gxFont family, long index, gxFontPlatform platform, gxFontScript script, gxFontLanguage language,
  173.     long nameLength, const unsigned char *name)
  174. {
  175.     gxFont fontID = nil;
  176.  
  177.     if (index)
  178.         GXFindFonts(family, 0, 0, 0, 0, 0, nil, index, 1, &fontID);
  179.     else
  180.         GXFindFonts(family, gxStyleFontName, platform, script, language, nameLength, name, index, 1, &fontID);
  181.     return fontID;
  182. }
  183.  
  184. /****************************
  185.         Style matching routines
  186.  ****************************/
  187.  
  188. typedef struct {
  189.     Fixed       minValue;
  190.     Fixed       defaultValue;
  191.     Fixed       maxValue;
  192. } descriptorRange;
  193.  
  194. typedef struct {
  195.     descriptorRange weight;
  196.     descriptorRange width;
  197.     descriptorRange slant;
  198. } fontMatchDescriptor;
  199.  
  200. typedef struct {
  201.     Fixed       weight;
  202.     Fixed       width;
  203.     Fixed       slant;
  204. } fontStyleCoord;
  205.  
  206. /*********************************************/
  207. /*              PrepareStyleForMatching                 */
  208. /*  this sets the styles gxFont variations to that of the current gxFont    */
  209. /*  we'll use this as a master and keep it to do our matching off of    */
  210. /*  if the gxStyle already has variations then we'll check to see if  */
  211. /*  the gxFont has axes, if not we'll nuke the variations and set new */
  212. /*  ones based upon the 'fdsc' information(GXFindFontDescriptor should*/
  213. /*  look at the fond header for old type fonts      ???         */
  214. /*********************************************/
  215. static void PrepareStyleForMatching(gxStyle aStyle)
  216. {
  217.     fontStyleCoord coord;
  218.     gxFont fontID = GXGetStyleFont(aStyle);
  219.     
  220.     coord.weight = fixed1;
  221.     coord.width = fixed1;
  222.     coord.slant = 0;
  223.  
  224.     GXFindFontDescriptor(fontID, weightVariationTag, &coord.weight);  
  225.     GXFindFontDescriptor(fontID, widthVariationTag, &coord.width);    
  226.     GXFindFontDescriptor(fontID, slantVariationTag, &coord.slant);    
  227.  
  228.     /* if (!( GXGetStyleFontVariations(aStyle, nil))) */
  229.     {   gxFontVariation* variations = (gxFontVariation*)NewPtr(3 * sizeof(gxFontVariation));
  230.         {   variations[0].name = weightVariationTag;    /*will actually check to see if current variations are set*/
  231.             variations[0].value = coord.weight; /*then we'll append any needed ones*/
  232.             variations[1].name = widthVariationTag; /*need a new routine that will set and create if needed*/
  233.             variations[1].value = coord.width;
  234.             variations[2].name = slantVariationTag;
  235.             variations[2].value = coord.slant;
  236.         }
  237.         GXSetStyleFontVariations(aStyle, 3, variations);
  238.         DisposePtr((Ptr)variations);
  239.     }
  240. }
  241.  
  242. /*
  243.  *  This builds a complete description of a gxFont as it is being used in a gxStyle.
  244.  *  Use this to compare against the styles in another gxFont family, to find the closest match.
  245.  */
  246. static void BuildFontStyleCoord(gxStyle aStyle, fontStyleCoord* coord)
  247. {
  248.     gxFont fontID = GXGetStyleFont(aStyle);
  249.     long i, count;
  250.     Fixed value;
  251.     gxFontTableTag aTag;
  252.  
  253.     coord->weight = fixed1;
  254.     coord->width = fixed1;
  255.     coord->slant = 0;
  256.  
  257.     GXFindFontDescriptor(fontID, weightVariationTag, &coord->weight); 
  258.     GXFindFontDescriptor(fontID, widthVariationTag, &coord->width);   
  259.     GXFindFontDescriptor(fontID, slantVariationTag, &coord->slant);   
  260.     
  261.     count = GXGetStyleFontVariations(aStyle, nil);
  262.     if (count)
  263.     {   gxFontVariation* variations = (gxFontVariation*)NewPtr(count * sizeof(gxFontVariation));
  264.         GXGetStyleFontVariations(aStyle, variations);
  265.         for (i = 0; i < count; i++)
  266.         {   aTag = variations[i].name;
  267.             value = variations[i].value;
  268.             if (aTag == weightVariationTag)
  269.                 coord->weight = value;
  270.             else if (aTag == widthVariationTag)
  271.                 coord->width = value;
  272.             else if (aTag == slantVariationTag)
  273.                 coord->slant = value;
  274.         }
  275.         DisposePtr((Ptr)variations);
  276.     }
  277. }
  278.  
  279. /*
  280.  *  This builds a complete description of a gxFont, giving its ranges for the various styles
  281.  *      weight, width, slant.
  282.  *  If the gxFont does not support a range for a given gxStyle, then min = max = default.
  283.  */
  284. static void BuildFontMatchDescriptor(gxFont fontID, fontMatchDescriptor* descriptor)
  285. {
  286.  
  287.     descriptor->weight.minValue = descriptor->weight.defaultValue = descriptor->weight.maxValue = 0;
  288.     descriptor->width.minValue = descriptor->width.defaultValue = descriptor->width.maxValue = 0;
  289.     descriptor->slant.minValue = descriptor->slant.defaultValue = descriptor->slant.maxValue = 0;
  290.  
  291.     if (GXFindFontDescriptor(fontID, weightVariationTag, &descriptor->weight.defaultValue))
  292.         descriptor->weight.minValue = descriptor->weight.maxValue = descriptor->weight.defaultValue;
  293.     if (GXFindFontDescriptor(fontID, widthVariationTag, &descriptor->width.defaultValue))
  294.         descriptor->width.minValue = descriptor->width.maxValue = descriptor->width.defaultValue;
  295.     if (GXFindFontDescriptor(fontID, slantVariationTag, &descriptor->slant.defaultValue))
  296.         descriptor->slant.minValue = descriptor->slant.maxValue = descriptor->slant.defaultValue;
  297.  
  298.     GXFindFontVariation(fontID, weightVariationTag, &descriptor->weight.minValue, &descriptor->weight.defaultValue, &descriptor->weight.maxValue, nil);
  299.     GXFindFontVariation(fontID, widthVariationTag, &descriptor->width.minValue, &descriptor->width.defaultValue, &descriptor->width.maxValue, nil);
  300.     GXFindFontVariation(fontID, slantVariationTag, &descriptor->slant.minValue, &descriptor->slant.defaultValue, &descriptor->slant.maxValue, nil);
  301. }
  302.  
  303. /*
  304.  *  This needs to scale each difference by some amount that balances the various styles
  305.  *      weight, width, slant
  306.  *  This could be a global table, or possible gxFont defined?
  307.  */
  308. static Fixed ComputeDescriptorMetric(fontStyleCoord* coord, fontMatchDescriptor* descriptor, fontStyleCoord* setting, fontStyleCoord* remaining)
  309. {
  310.     Fixed distance = 0;
  311.     fontStyleCoord remainBuffer;
  312.  
  313.     if (remaining == nil)
  314.         remaining = &remainBuffer;
  315.  
  316.     remaining->weight = remaining->width = remaining->slant = 0;
  317.                                                                 /*setting must fall within the range of descriptor min and max*/
  318.     setting->weight = (coord->weight < descriptor->weight.maxValue) ? coord->weight: descriptor->weight.maxValue;/* min of the maximums*/
  319.     setting->weight = (setting->weight > descriptor->weight.minValue) ? setting->weight: descriptor->weight.minValue;/* max of the minimums*/
  320.     remaining->weight = coord->weight - setting->weight;    /* if positive then we need to add more bolding with a textface, if negative we need to take some away*/
  321.     distance += (remaining->weight > 0) ? FixedMultiply(remaining->weight , prefwghtweighting): -FixedMultiply(remaining->weight , prefwghtweighting);/*absolute value for distance metric */
  322.     
  323.     setting->width = (coord->width < descriptor->width.maxValue) ? coord->width: descriptor->width.maxValue;/* min of the maximums*/
  324.     setting->width = (setting->width > descriptor->width.minValue) ? setting->width: descriptor->width.minValue;/* max of the minimums*/
  325.     remaining->width = coord->width - setting->width;   /* if positive then we need to extend via textface, if negative we need to condense*/
  326.     distance += (remaining->width > 0) ? FixedMultiply(remaining->width , prefwdthweighting): -FixedMultiply(remaining->width , prefwdthweighting);/*absolute value for distance metric  */
  327.  
  328.     setting->slant = (coord->slant < descriptor->slant.maxValue) ? coord->slant: descriptor->slant.maxValue;/* min of the maximums*/
  329.     setting->slant = (setting->slant > descriptor->slant.minValue) ? setting->slant: descriptor->slant.minValue;/* max of the minimums*/
  330.     remaining->slant = coord->slant - setting->slant;   /* if positive then we need to skew clockwise via textface, if negative we need to skew counter clockwise*/
  331.     /*actually, if there is any slant at all in the coord->slant then we don't want to make an italic gxFont more italic*/
  332.     distance += (remaining->slant > 0) ? FixedMultiply(remaining->slant, prefslntweighting): -FixedMultiply(remaining->slant, prefslntweighting);/*absolute value for distance metric  this is naturally weighted to be last pref*/
  333.     /* could use something like this and then weight it??? distance += FixedDivide(remaining->slant, ff(90) ); */
  334.     if(setting->slant)
  335.         remaining->slant = 0;
  336.  
  337.     return distance;
  338. }
  339.  
  340. static void AppendVariation(gxFontVariation** variation, gxFontTableTag aTag, Fixed value)
  341. {
  342.     gxFontVariation* var;
  343.     long size = GetHandleSize((Handle)variation);
  344.     
  345.     SetHandleSize((Handle)variation, size + sizeof(gxFontVariation));
  346.     var = (gxFontVariation*)((char*)*variation + size);
  347.     var->name = aTag;
  348.     var->value = value;
  349. }
  350.  
  351. static void CreateCoordVariations(fontStyleCoord* setting, fontMatchDescriptor* descriptor, gxFontVariation* variation)
  352. {
  353.     long count = 0;
  354.  
  355.     if (setting->weight != descriptor->weight.defaultValue)
  356.     {   variation[count].name = weightVariationTag;
  357.         variation[count].value = setting->weight;
  358.         count++;
  359.     }
  360.     if (setting->width != descriptor->width.defaultValue) count++;
  361.     {   variation[count].name = widthVariationTag;
  362.         variation[count].value = setting->width;
  363.         count++;
  364.     }
  365.     if (setting->slant != descriptor->slant.defaultValue) count++;
  366.     {   variation[count].name = slantVariationTag;
  367.         variation[count].value = setting->slant;
  368.         count++;
  369.     }
  370. }
  371.  
  372. /*  currently CreateCoordTextFace makes up the difference between the variation axes and the actual settings of the old gxStyle*/
  373. static gxTextFace* CreateCoordTextFace(fontStyleCoord* remainingCoord, fontMatchDescriptor* descriptor)
  374. {
  375.     gxTextFace* newFace;
  376.     Fixed newBoldAddition = 0;
  377.     
  378.     newFace = (gxTextFace*)NewPtr(sizeof(gxTextFace) +  (1 - gxAnyNumber) * sizeof(gxFaceLayer));
  379.     newFace->faceLayers = 1;
  380.     ResetMapping(&newFace->advanceMapping);
  381.  
  382.     newFace->faceLayer[0].outlineStyle = nil;
  383.     newFace->faceLayer[0].outlineFill = gxSolidFill;
  384.     newFace->faceLayer[0].flags = 0;
  385.     /*X=default length, Y = desired percentage bold, x = setting weight, y =new percentage bold to apply*/
  386.     /*  y = XY/x    */      /*newBoldAddition = FixedDivide( FixedMultiply(remainingCoord->weight, descriptor->weight.defaultValue), setting->weight);*/
  387.      if ( (remainingCoord->weight) && (descriptor->weight.defaultValue == fixed1) ) /*if there is bold left and the gxFont is not natuarally bold*/
  388.         /*newBoldAddition = FixedDivide( FixedMultiply(remainingCoord->weight, descriptor->weight.defaultValue), setting->weight);*/
  389.         newBoldAddition = fixed1/12;  /*this is just a temporary hack until textfaces are nailed down????*/
  390.     newBoldAddition *= (remainingCoord->weight > 0) ? 1: -1;    /*increase or decrease weight*/
  391.     newFace->faceLayer[0].boldOutset.x = newBoldAddition;   /*if negative this makes lighter???*/
  392.     newFace->faceLayer[0].boldOutset.y = 0;
  393.  
  394.     if (remainingCoord->width || remainingCoord->slant)
  395.     {   gxTransform curTransform = newFace->faceLayer[0].outlineTransform = GXNewTransform();
  396.         if (remainingCoord->width)
  397.         {   Fixed newWidthFactor = fixed1+ remainingCoord->width;
  398.             GXScaleTransform(curTransform, newWidthFactor, fixed1, 0, 0);
  399.         }
  400.         if (remainingCoord->slant)
  401.             GXSkewTransform(curTransform, -fixed1/4, 0, 0, 0);/*should do a slope from angle????*/
  402.     }
  403.     else
  404.         newFace->faceLayer[0].outlineTransform = nil;
  405.     return newFace;
  406. }
  407.  
  408. static gxFont FindMatchingFont(gxStyle currentStyle, gxFont targetFamily, gxFontVariation* newVariations, gxTextFace** newFace)
  409. {
  410.     Fixed bestMetric = ff(32767);
  411.     gxFont bestFont = targetFamily;
  412.     fontStyleCoord currentCoord, bestRemaining, bestSetting;
  413.     fontMatchDescriptor bestDesc;
  414.     long styleIndex, styleCount;
  415.  
  416.     BuildFontStyleCoord(currentStyle, ¤tCoord);   /*maybe take this out later??? use preparestyleformatching*/
  417.  
  418.     styleCount = CountFontStyles(targetFamily);
  419.     for (styleIndex = 1; styleIndex <= styleCount; styleIndex++)
  420.     {   Fixed metric;
  421.         gxFont targetFont = GetFontStyle(targetFamily, styleIndex);
  422.         fontStyleCoord remainingCoord, targetSetting;
  423.         fontMatchDescriptor targetDescriptor;
  424.  
  425.         BuildFontMatchDescriptor(targetFont, &targetDescriptor);
  426.         if(!GXGetFont(targetFont, nil, nil))
  427.         {
  428. #ifdef debugging
  429.             DebugStr((const unsigned char *)"\pError in FindMatchingFont with targetFont");
  430. #endif
  431.     }
  432.         metric = ComputeDescriptorMetric(¤tCoord, &targetDescriptor, &targetSetting, &remainingCoord);
  433.         if (metric < bestMetric)
  434.         {   bestMetric = metric;
  435.             bestFont = targetFont;
  436.             bestDesc = targetDescriptor;
  437.             bestSetting = targetSetting;
  438.             bestRemaining = remainingCoord;
  439.         }
  440.     }
  441.     if (newVariations)  /*new way we won't have to do this?????*/
  442.         CreateCoordVariations(&bestSetting, &bestDesc, newVariations);
  443.     if (newFace)
  444.         *newFace = bestMetric ? CreateCoordTextFace(&bestRemaining, &bestDesc) : nil;
  445.  
  446.     return bestFont;
  447. }
  448.  
  449. static void DisposeFaceParts(gxTextFace *newFace)
  450. {
  451.     long activeLayer = newFace->faceLayers - 1;
  452.  
  453.     do {
  454.         if (newFace->faceLayer[activeLayer].outlineStyle)
  455.             GXDisposeStyle(newFace->faceLayer[activeLayer].outlineStyle);
  456.         if (newFace->faceLayer[activeLayer].outlineTransform)
  457.             GXDisposeTransform(newFace->faceLayer[activeLayer].outlineTransform);
  458.     } while (--activeLayer >= 0);
  459.     DisposePtr((Ptr) newFace);
  460. }
  461.  
  462.  
  463. void SetMatchingStyle(gxFont targetFamily, gxStyle theStyle, long matchInfo)
  464. {
  465.     gxFont toFont;
  466.     gxTextFace *newFace = nil;
  467.     gxFontVariation newVariations[3];/*will only match on wght, wdth, slnt*/
  468.     gxFont fromFont = GXGetStyleFont(theStyle);
  469.     Boolean toggle = false;
  470.     
  471.     if ( !( GXGetStyleFontVariations(theStyle, nil)) )
  472.         PrepareStyleForMatching(theStyle);
  473.     if(matchInfo & useTextFaceMatching)
  474.     {
  475.         if(matchInfo & useVariationsMatching)
  476.             toFont = FindMatchingFont(theStyle, targetFamily, newVariations, &newFace);
  477.         else
  478.             toFont = FindMatchingFont(theStyle, targetFamily, nil, &newFace);
  479.     }
  480.     if(!(matchInfo & useTextFaceMatching))
  481.     {
  482.         if(matchInfo & useVariationsMatching)
  483.             toFont = FindMatchingFont(theStyle, targetFamily, newVariations, nil);
  484.         else
  485.             toFont = FindMatchingFont(theStyle, targetFamily, nil, nil);
  486.     }
  487.  
  488.     
  489.     GXSetStyleFont(theStyle, toFont);
  490.     GXSetStyleFace(theStyle, nil);    /*remove any textfaces set  will have to do this selectively in the future???*/
  491.     
  492.     if(matchInfo & useVariationsMatching)
  493.     {   short varCount = GXCountFontVariations(toFont);
  494.     
  495.         if(varCount)
  496.             GXSetStyleFontVariations(theStyle, varCount, newVariations);
  497.     }
  498.     if(matchInfo & useTextFaceMatching)
  499.     {
  500.         if(newFace)
  501.             GXSetStyleFace(theStyle, newFace);
  502.     }   
  503.     if (newFace)
  504.         DisposeFaceParts(newFace);
  505. }
  506.  
  507. gxStyle ReturnMatchingStyle(gxFont targetFamily, gxStyle theStyle, matchingStyle matchInfo)
  508. {   gxStyle aStyle = GXCopyToStyle(nil, theStyle);
  509.     SetMatchingStyle(targetFamily, aStyle, matchInfo);
  510.     return(aStyle);
  511. }
  512.